package com.learn.scrm;


import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.ToString;
import org.apache.commons.lang3.StringUtils;

/**
 * 角色枚举类
 */
@AllArgsConstructor
@Getter
@ToString
public enum RoleEnum {
    SERVICE_CHIEF("00000020", "服务总监"),
    DDC_MANAGER("00000002", "DDC经理"),
    BIG_CUSTOMER_MANAGER("00000017", "大客户经理"),
    BIG_CUSTOMER_APPROVE("000010", "厂家大客户区域审核员"),
    BIG_CUSTOMER_ADMINISTRATORS("000011", "厂家大客户管理员"),
    CUSTOMER_MANAGER("00000008", "客户经理"),
    CALL_BACK("00000015", "回访专员"),
    MARKET_MANAGER("00000014", "市场经理"),
    CALLER_SELLER("00000001", "电销员"),
    LOGISTICS_MANAGER("00000009", "物流经理"),
    HALL_SALES("00000003", "销售顾问"),//展厅顾问
    HALL_MANAGER("00000005", "展厅经理"),
    SALES_FRONT("00000006", "销售前台"),
    GENERAL_MANAGER("00000007", "总经理"),
    SALES_CHIEF("00000018", "销售总监"),
    SHOP_ADMIN("00000000", "专营店管理员"),
    INFORMATION("00000019", "信息化专员"),
    CLUE_CLEAR("00000022", "线索清洗员"),
    TRY_DRIVER("00000161", "试驾员"),
    SHOP_MANAGER("10000001", "店长"),
    USER_DEVELOP_MANAGER("10000002", "用户发展经理"),
    USER_PARTNER("10000003", "用户伙伴"),
    DELIVERY_MANAGER("10000004", "交付经理"),
    DELIVERY_SPECIALIST("10000005", "交付专员"),
    DATA_OPERATIONS_SPECIALIST("10000006", "数据运营专员"),
    DEFEAT_RETURN_VISIT("10000008", "战败回访员"),
    DEFEAT_RETURN_VISIT_NEW_SALE("10000009", "新零售战败回访员"),
    BLOC_VISIT("10000016", "集团回访员"),
    ;


    private String code;
    private String msg;

    /**
     * 根据code获取msg
     *
     * @param status
     * @return
     */
    public static String getMsgByCode(RoleEnum status) {
        String code = status.getCode();
        for (RoleEnum c : RoleEnum.values()) {
            if (c.getCode().equals(status.getCode())) {
                return c.getMsg();
            }
        }
        return null;
    }

    public static RoleEnum getByCode(String code) {
        if (StringUtils.isBlank(code)) {
            return HALL_SALES;
        }
        for (RoleEnum c : RoleEnum.values()) {
            if (c.getCode().equals(code)) {
                return c;
            }
        }
        return HALL_SALES;
    }
    public static RoleEnum getByCodeNoDefault(String code) {
        if (StringUtils.isBlank(code)) {
            return null;
        }
        for (RoleEnum c : RoleEnum.values()) {
            if (c.getCode().equals(code)) {
                return c;
            }
        }
        return null;
    }
}
